/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package wikitrafic.iovanalex.ro;

import java.util.ArrayList;

/**
 *
 * @author Administrator
 */
public class TraceLog {

    private ArrayList<TraceItem> traces;
    private int uid;
    private String startDate;


   

    public TraceLog(String id, String startdate, ArrayList<TraceItem> traces) {
        this.startDate = startdate;
        this.uid = Integer.parseInt(id);
        this.traces = traces;
    }

    

//    public ArrayList<TraceItem> analyseLog() {
//        TraceItem trace[] = new TraceItem[traces.size()];
//        trace = traces.toArray(trace);
//        ArrayList db=new ArrayList<TraceItem>();
//
//        for (int i = 0; i <= trace.length - 2; i++) {
//            GPSPoint p1 = trace[i].getPoint();
//            GPSPoint p2 = trace[i + 1].getPoint();
//            double distance = p1.getDistanceInMeters(p1, p2);
//            double sampleTime = trace[i + 1].getTimestamp() - trace[i].getTimestamp();
//            double spd = (distance / sampleTime) * 3.6;
//
//            //TraceItem tdbi=new TraceItem(uid, trace[i+1].getTimestamp(), p2.getLat(), p2.getLon(), p2.getAlt(), trace[i+1].getConfidanceRadius(), spd);
//            //db.add(tdbi);
//            //System.out.println(distance+ "m; speed="+ spd+" km/h");  //ok - tested
//
//        }
//        return db;
//    }
    public int getUid(){
        return uid;
    }
    public ArrayList<TraceItem> getTraces(){
        return traces;
    }
    public int getNoOfTraces(){
        return traces.size();
    }
    public int getStartDate(){
        return traces.get(0).getTimestamp();
    }
    public int getEndDate(){
        return traces.get(traces.size()-1).getTimestamp();
    }
    

    

    public String getSqlInsert(String tablename) {
        /*
         * INSERT INTO Logs (startTime, endTime, noOfRec,uid) VALUES (102012,1122010,1839,1) ->logId
         * INSERT INTO Points (lat,lon) VALUES (roundLat, roundLon); ->pointId
         * INSERT INTO Lines (startPointId, endPointId, length) VALUES (123,321,12,4) -> lineId
         * INSERT INTO Traces (lineId, timestamp,speed,logId) VALUES (lineId, 213412, 24.3, logId);
         * insert into test (col1, col2) select valoare1 as a, valoare2 as b from test where col1 <> valoare1 and col2 <> valoare2
         */

        int startTime = 0,endTime = 0, noOfRec = 0, length = 0,roundLat=0,roundLon=0;
        String logStmt="INSERT INTO Logs (startTime, endTime, noOfRec, uid) VALUES ("+102012+", "+1122010+ ", "+1839+","+1+")";
       // String ptStmt="INSERT INTO Points ("+roundLat+", "+roundLon+", ) SELECT lat AS lt, lon AS lo FROM Points WHERE lon<>"+this.roundLat+" AND lat<>"+this.roundLon;
        String lnStmt="INSERT INTO Lines (startPointId, endPointId, length) SELECT ";

        return "";
    }

   
}
